package com.xueyi.bidding.controller;

import com.xueyi.bidding.domain.dto.BiddingTestDto;
import com.xueyi.bidding.service.IBiddingTestService;
import com.xueyi.common.web.entity.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xueyi.common.security.annotation.Logical;
import com.xueyi.common.security.annotation.RequiresPermissions;
import com.xueyi.common.core.web.validate.V_A;
import com.xueyi.common.core.web.validate.V_E;
import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.log.annotation.Log;
import com.xueyi.common.log.enums.BusinessType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.List;

/**
 * test管理 业务处理
 *
 * @author leizhao
 */
@RestController
@Api(value = "部门控制器", tags = {"部门管理"})
@RequestMapping("/test")
public class BiddingTestController extends BaseController<BiddingTestDto, IBiddingTestService> {

    /** 定义节点名称 */
    @Override
    protected String getNodeName() {
        return "test";
    }

    /**
     * 查询test列表
     */
    @Override
    @ApiOperation("查询test列表")
    @GetMapping("/list")
    @RequiresPermissions(Auth.BIDDING_TEST_LIST)
    public AjaxResult list(BiddingTestDto biddingTest) {
        return super.list(biddingTest);
    }

    /**
     * 查询test详细
     */
    @Override
    @ApiOperation("查询test详细")
    @GetMapping(value = "/{id}")
    @RequiresPermissions(Auth.BIDDING_TEST_SINGLE)
    public AjaxResult getInfoExtra(@PathVariable Serializable id) {
        return super.getInfoExtra(id);
    }

    /**
     * test导出
     */
    @Override
    @ApiOperation("test导出")
    @PostMapping("/export")
    @RequiresPermissions(Auth.BIDDING_TEST_EXPORT)
    @Log(title = "test管理", businessType = BusinessType.EXPORT)
    public void export(HttpServletResponse response, BiddingTestDto biddingTest) {
        super.export(response, biddingTest);
    }

    /**
     * test新增
     */
    @Override
    @ApiOperation("test新增")
    @PostMapping
    @RequiresPermissions(Auth.BIDDING_TEST_ADD)
    @Log(title = "test管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody BiddingTestDto biddingTest) {
        return super.add(biddingTest);
    }

    /**
     * test修改
     */
    @Override
    @ApiOperation("test修改")
    @PutMapping
    @RequiresPermissions(Auth.BIDDING_TEST_EDIT)
    @Log(title = "test管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody BiddingTestDto biddingTest) {
        return super.edit(biddingTest);
    }

    /**
     * test修改状态
     */
    @Override
    @ApiOperation("test修改状态")
    @PutMapping("/status")
    @RequiresPermissions(value = {Auth.BIDDING_TEST_EDIT, Auth.BIDDING_TEST_ES}, logical = Logical.OR)
    @Log(title = "test管理", businessType = BusinessType.UPDATE_STATUS)
    public AjaxResult editStatus(@RequestBody BiddingTestDto biddingTest) {
        return super.editStatus(biddingTest);
    }

    /**
     * test批量删除
     */
    @Override
    @ApiOperation("test批量删除")
    @DeleteMapping("/batch/{idList}")
    @RequiresPermissions(Auth.BIDDING_TEST_DEL)
    @Log(title = "test管理", businessType = BusinessType.DELETE)
    public AjaxResult batchRemove(@PathVariable List<Long> idList) {
        return super.batchRemove(idList);
    }

    /**
     * 获取test选择框列表
     */
    @Override
    @ApiOperation("获取test选择框列表")
    @GetMapping("/option")
    public AjaxResult option() {
        return super.option();
    }

    interface Auth {
        /** 系统 - test管理 - 列表 */
        String BIDDING_TEST_LIST = "test:test:list";
        /** 系统 - test管理 - 详情 */
        String BIDDING_TEST_SINGLE = "test:test:single";
        /** 系统 - test管理 - 新增 */
        String BIDDING_TEST_ADD = "test:test:add";
        /** 系统 - test管理 - 修改 */
        String BIDDING_TEST_EDIT = "test:test:edit";
        /** 系统 - test管理 - 修改状态 */
        String BIDDING_TEST_ES = "test:test:es";
        /** 系统 - test管理 - 删除 */
        String BIDDING_TEST_DEL = "test:test:delete";
        /** 系统 - test管理 - 导出 */
        String BIDDING_TEST_EXPORT = "test:test:export";
    }
}
